package net.zisen.cloud.wallet.ctrl;

import net.zisen.cloud.base.msg.ResultMsg;
import net.zisen.cloud.wallet.client.WalletClient;
import net.zisen.cloud.wallet.service.WalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author tim/278002989@qq.com
 * @Classname WalletCtrl
 * @Description TODO
 * @Date 2019-05-17 19:16
 */
@RestController
public class WalletCtrl implements WalletClient {


    @Autowired
    private WalletService service;

    /**
     * 扣除钱包金额
     *
     * @param uid
     * @param amount
     * @param num
     * @param description
     * @return
     */
    @Override
    @RequestMapping(value = "wallet/deduct", method = RequestMethod.GET)
    public ResultMsg deduct(Long uid, BigDecimal amount, String num, String description) {
        return this.service.deduct(uid, amount, num, description);
    }

    /**
     * 查询钱包余额
     *
     * @param uid
     * @return
     */
    @Override
    @RequestMapping(value = "wallet/balance", method = RequestMethod.GET)
    public ResultMsg<BigDecimal> checkWalletBalance(Long uid) {
        return this.service.checkWalletBalance(uid);
    }
}
